package com.zrkizzy.seckill.utils;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * 时间工具类
 *
 * @author zhangrongkang
 * @since 2023/4/6
 */
public class TimeUtil {

    /**
     * 获取当前和指定时间相差的描述
     *
     * @param time 指定时间
     * @return 相差秒数
     */
    public static long secondIntervalNow(LocalDateTime time) {
        return Math.abs(Duration.between(time, LocalDateTime.now()).toSeconds());
    }

    public static void main(String[] args) {
        System.out.println(secondIntervalNow(LocalDateTime.of(2023, 4, 6, 9, 58)));
    }
}
